import { getHandleInsuranceReportList } from '@/api/insurance/report'
import type { HandleInsuranceReportDto } from '@/api/insurance/report/types'
import { getKeyToEnum, InsuranceReprotCaseStatusCnEnum } from '@/const/enum'
import type { FilterDto } from '@/render/FilterRender'
import TableRender, { type TableRenderColumnTypes } from '@/render/TableRender'
import type { AnyObject } from '@/types'
import toNative from '@/utils/toNative'
import { Button } from 'ant-design-vue'
import { Component } from 'vue-facing-decorator'
import type { VxeColumnSlotTypes, VxeGridProps, VxeGridPropTypes, VxeTableDataRow } from 'vxe-table'

@Component
export class InsuranceReportClaimTip extends TableRender {
    filterConfig(): FilterDto {
        return {
            searchText: {
                name: '客户或商务名称',
                element: 'input',
            },
            salesId: {
                name: '商务负责人',
                element: 'select',
                optionsType: 'sale'
            },
            datetime: {
                name: '日期',
                element: 'datetime',
                type: 'daterange'
            },
            reportStatus: {
                name: '状态',
                element: 'select',
                options: getKeyToEnum(InsuranceReprotCaseStatusCnEnum),
                params: {
                    clearable: true
                }
            }
        }
    }
    onLoadData(pageNum: number, pageSize: number, filters: AnyObject){
        return getHandleInsuranceReportList({
            pageNum,
            pageSize,
            sortField: this.sortFields[0]?.field ?? '',
            sortType: this.sortFields[0]?.order ?? '',
            ...filters
        })
    }

    tableColumnConfigOld = () => [
        {
            field: 'companyName',
            title: '客户名称',
        },
        {
            field: 'saleName',
            title: '商务负责人',
        },
        {
            field: 'deptName',
            title: '所属分组',
        },
        {
            field: 'productOpenTime',
            title: '产品',
            formatter: ({ row, column }: VxeColumnSlotTypes.ContentSlotParams<HandleInsuranceReportDto>) => {
                return row.insuranceType === 2 ? '日日保' : '长期保'
            }
        },
        {
            field: 'outDangerUserName',
            title: '出险人姓名'
        },
        {
            field: 'outDangerDate',
            title: '出险时间',
            sortable: true
        },
        {
            field: 'reportStatus',
            title: '状态',
            formatter: ({ row, column }: VxeColumnSlotTypes.ContentSlotParams<HandleInsuranceReportDto>) => {
                return InsuranceReprotCaseStatusCnEnum[row.reportStatus]
            },
            params: {
                colors: ['blue-default', 'yellow', 'green', 'red', 'gray-light-200'],
            },
            slots: {
                default: 'color'
            }
        },
        {
            field: 'reportCaseResultList.0.remark',
            title: '最新进展'
        },
        {
            field: 'operate',
            title: '操作',
            fixed: 'right',
            slots: {
                default: ({ row, column }: VxeColumnSlotTypes.ContentSlotParams<HandleInsuranceReportDto>) => {
                    return <>
                        <Button type="text">查看详情</Button>
                    </>
                }
            }
        }
    ] as TableRenderColumnTypes<HandleInsuranceReportDto>



}

export default toNative(InsuranceReportClaimTip)
